package cn.edu.ctbu.test.service.impl;

import cn.edu.ctbu.test.dao.ScRepository;
import cn.edu.ctbu.test.domain.Sc;
import cn.edu.ctbu.test.service.ScService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScServiceImpl implements ScService {
    
    @Autowired
    ScRepository scRepository;

    @Override
    public List<Sc> findAll(){

        return scRepository.findAll();
    }



    @Override
    public Page<Sc> findAll(Pageable pageable) {


        return scRepository.findAll(pageable);

    }


    @Override
    public Page<Sc> findAll(Example<Sc> sc, Pageable pageable){

        return scRepository.findAll(sc,pageable);
    }





    /**
     * zsgc
     * @param sc
     * @return
     */


    public Sc insert(Sc sc){

        return scRepository.save(sc);
    }

    public void delete(Long studentId){
        Sc sc=new Sc();
        sc.setStudentId(studentId);
        scRepository.delete(sc);
    }

    public Sc getById(Long studentId){

        Sc sc=scRepository.findById(studentId).orElse(null);

        return sc;
    }

    public Sc update(Sc sc){

        return  scRepository.save(sc);
    }
    public List<Sc> findScByStudentName(String name) {
        return  scRepository.findScByStudentName(name);
    }
    
   
    
}
